﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;

namespace DeqiYQ.SQLConn
{
    public class Weather
    {


        public static Dictionary<string,object> GetWeater()
        {
           
            string url = "https://www.tianqiapi.com/api?version=v6&appid=35194244&appsecret=oNwQO50W&cityid=101040100";

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "GET";
            request.Timeout = 5000;
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            string jsonString;
            using (Stream stream = response.GetResponseStream())   
            {
                StreamReader reader = new StreamReader(stream, System.Text.Encoding.UTF8);
                jsonString = reader.ReadToEnd();
            }

            Dictionary<string,object> dict= JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonString);

            //取值方式

            return dict;

        }




    }
}